package com.yand.redis;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;

public class FunnelLimitRateTest {

    private static Map<String,Funnel> funnels = new HashMap<>();

    public static void main(String [] args) throws InterruptedException {
        String userId= "2019";
        String actionKey = "rgister";
        int capacity = 10;
        double leakingRate= 0.1;
        Funnel funnel = funnels.get(userId);
        if (funnel==null){
            funnel = new Funnel(capacity, leakingRate, 10, System.currentTimeMillis());
        }
        for (int i = 0; i < 30; i++) {
            Boolean water = funnel.water(1);
            TimeUnit.MILLISECONDS.sleep(1);
            System.out.println(water+ " "+funnel.leftQuota);
        }

    }
}
